package tk.djcrazy.instantmessage.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import tk.djcrazy.instantmessage.service.IFriendGroupService;
import tk.djcrazy.instantmessage.service.IFriendshipService;

import com.opensymphony.xwork2.ActionSupport;

public class DeleteFriendship extends ActionSupport implements SessionAware {
	private static final long serialVersionUID = 5381777409966754355L;
	private int uid;
	private int groupId;

	private String result = "failed";
	private String message;
	private IFriendshipService friendshipService;
	private IFriendGroupService friendGroupService;
	private Map<String, Object> session;

	public String execute() {
		try {
			friendGroupService.deleteFriendFromGroup(groupId, uid);
			friendshipService.deleteFriendShip((Integer) session.get("uid"),
					uid);
			result = "success";
		} catch (Exception e) {
			e.printStackTrace();
			result = "failed";
		}
		return SUCCESS;
	}

	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}

	public IFriendshipService getFriendshipService() {
		return friendshipService;
	}

	public void setFriendshipService(IFriendshipService friendshipService) {
		this.friendshipService = friendshipService;
	}

	public IFriendGroupService getFriendGroupService() {
		return friendGroupService;
	}

	public void setFriendGroupService(IFriendGroupService friendGroupService) {
		this.friendGroupService = friendGroupService;
	}

	public Map<String, Object> getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public int getGroupId() {
		return groupId;
	}

	public void setGroupId(int groupId) {
		this.groupId = groupId;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}
